package com.zengqingfa.shardingjdbc.demo.dao;

import cn.hutool.core.util.RandomUtil;
import com.zengqingfa.shardingjdbc.demo.ShardingJdbcApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * @fileName: OrderDaoTest
 * @author: zengqf3
 * @date: 2021-3-15 10:56
 * @description:
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ShardingJdbcApplication.class)
public class OrderDaoTest2 {

    @Autowired
    private OrderDao2 OrderDao2;

    @Test
    public void testInsertOrder() {

        for (int i = 0; i < 10; i++) {
            OrderDao2.insertOrder(new BigDecimal((i + 1)), Long.valueOf(RandomUtil.randomInt(1, 1000)), "WAIT_PAY");
        }

    }

    @Test
    public void testSelectOrderbyIds() {
        List<Long> ids = new ArrayList<>();
        ids.add(582874982099451905L);
        ids.add(582874982099451904L);
        List<Map> maps = OrderDao2.selectOrderbyIds(ids);
        System.out.println(maps);

    }


    @Test
    public void testSelectOrderUserbyIds() {
        List<Long> ids = new ArrayList<>();
        ids.add(582876378542637057L);
        ids.add(582874982183337984L);
        List<Map> maps = OrderDao2.selectOrderbyUserAndIds(365, ids);
        System.out.println(maps);

    }

}
